package com.pdemo.front.rule;

import java.util.TreeSet;

import org.easyrules.core.AbstractRulesEngine;


public  class BaseRulesEngine<T> extends AbstractRulesEngine<BaseRule<T>> {

	@Override
	public void fireRules() {
		// do nothing
		
	}

	public void fireRules(T obj){
		// resort the rules;
		rules = new TreeSet<BaseRule<T>>(rules);
		for(BaseRule<T> r : rules){
			Status status = r.evaluateConditions(obj);
			if(Status.DO_SOMETHING.equals(status)){
				r.performActions(obj);
			}else if (Status.DO_NOTHING.equals(status)){
				continue;
			}else {
				return;
			}
		}
	}

	
}
